/* eslint-disable react/display-name */
import {  Drawer, Descriptions, DescriptionsProps, Alert } from "antd";
import React, { useState, useRef, memo, forwardRef, useImperativeHandle, useCallback } from "react";
import { User } from "./userApi";
import { DescriptionsItemType } from "antd/es/descriptions";
import { addDescriptionItem } from "@/utils/util";
// 密码重置 

export default memo(
	forwardRef(function ResetPass(props: any, ref: any) {
		const [open, setOpen] = useState<boolean>(false);
		const [items, setItems] = useState<DescriptionsProps['items']>([]);

		useImperativeHandle(ref, () => ({
			open: (info: User.PassResetResDTO) => {
				setOpen(true);
                let arr : DescriptionsItemType[] = []
                addDescriptionItem(arr,'用户名',info.username);
                addDescriptionItem(arr,'姓名',info.name);
                addDescriptionItem(arr,'密码',info.password);
                setItems(arr);
			}
		}));

		// 关闭抽屉
		const onClose = () => {
			setOpen(false);
		};

		return (
			<Drawer
				title={"密码重置"}
				width={720}
				onClose={onClose}
				open={open}
				styles={{
					body: {
						paddingBottom: 80
					}
				}}
			>
                <Alert message="密码重置成功" type="info" />
				<Descriptions style={{marginTop: 15}} column={1} items={items} />
			</Drawer>
		);
	})
);
